import QtQuick 2.0
import "../../js/util.js" as Util
import "../../js/UI.js" as Style

ACellRow {
    id: callde
    color: "transparent"
    height: 1.47 * m_lineValue
    property alias m_HeadSource: m_HeadImg_id.m_source
    property alias m_Nametext: m_NameText_id.text
    property alias m_CallStatuSource: m_CallStatuImg_id.source
    property alias m_CallStatuVisible: m_CallStatuImg_id.visible
    property alias m_DateTimetext: m_DateTimeText_id.text
    property alias m_phonetext: m_PhoneText_id.text
    property alias m_nameText: m_NameText_id
    signal clickSignal()
    signal pressAndHoldSignal()
    signal detailsSignal(string phoneStr)
    signal headClickSignal()
    signal pressedSignal()
    MouseArea {
        id: mouseArea
        onPressAndHold: pressAndHoldSignal()
        onPressed: pressedSignal()
        anchors.fill: center_Item
        onClicked: {
            clickSignal()
        }
    }
    states: State {
        name: "pressed"; when: mouseArea.pressed
        PropertyChanges { target: callde; color: Style.transparent_color;}
    }
    transitions: Transition {}
    m_leftItem: Item {
        id: leftItem
        width: height
        height: callde.height
        HeadImage {
            id: m_HeadImg_id
            width: parent.height*0.8;
            height: width
            anchors.centerIn: parent
            nameText: m_NameText_id.text.substring(0,1)
            colorText:m_NameText_id.text.length > 1 ? m_NameText_id.text.substring(1,2) : ""
            MouseArea{
                anchors.fill: parent
                onClicked: {
                    console.log("headisclic---------")
                    __InstanceMessage.setpersonInfoRecordList(m_phonetext)
                    headClickSignal();
                }
            }
        }
    }
    m_centerItem: Column {
        id: centerItem
        width: m_root_id.width - m_lineValue*3.24
        height: childrenRect.height
        spacing: Util.leftMargin
        AText {
            id: m_NameText_id
            font.pointSize: 16
            color: Style.fonttilteColor
            width: callde.width-m_DateTimeText_id.width-m_lineValue*0.6-callde.height
        }
        Row {
            spacing: Util.leftMargin*1.1
            Image {
                id: m_CallStatuImg_id
                width: m_lineValue/3
                height: m_lineValue/3
                source: if(parseInt(model.call_statu) === 0) "qrc:/images/callImage/calling.png"
                        else if(parseInt(model.call_statu) === 1) "qrc:/images/callImage/called.png"
                        else if(parseInt(model.call_statu) === 2 || parseInt(model.call_statu) === 3) "qrc:/images/callImage/call_missed.png"
                        else "qrc:/images/callImage/called.png"
            }

            AText {
                id: m_PhoneText_id
                font.pointSize: 14
                color: "#808080"
                width: callde.width-m_DateTimeText_id.width-m_lineValue*4/3-callde.height
                elide :Text.ElideRight
            }
        }
    }
    AText {
        id: m_DateTimeText_id
        anchors.right: ibtn.left

        width: paintedWidth
        height: parent.height
        verticalAlignment: Text.AlignVCenter
        text: Util.timeday(Qt.formatDateTime(model.start_time,"yyyy:MM:dd"),Qt.formatDateTime(model.start_time,"hh:mm"))
        font.pointSize: 12
        color: "#808080"
    }
    Item {
        id: ibtn
        width: m_lineValue*0.9
        height: parent.height
        anchors {
            right: parent.right
            verticalCenter: parent.verticalCenter
        }
        Image {
            visible:  m_DateTimeText_id.text !== ""
            width: m_lineValue*0.5
            anchors.centerIn: parent
            height: width
            fillMode: Image.PreserveAspectCrop
            source: "qrc:/images/tonghua_detail.svg"
            MouseArea {
                anchors.fill: parent
                onClicked: detailsSignal(m_PhoneText_id.text)
            }
        }
    }
    SplitLine {
        width: m_root_id.width - Util.leftMargin - (m_lineValue*1.47 - m_lineValue*1.47*0.8)/2
        anchors {
            bottom: parent.bottom
            right: parent.right;
        }
    }
}

